<?php

class GenerateRevocationForm extends AbstractForm {
	const NAME = 'generate';

	public function process() {
		return 'Your revocation code has been generated. Store this code in a safe and secure location. This code can be used to permanently delete all your stored passwords, and should be used in case of a lost YubiKey.<br />By creating this code, any previously generated revocations codes for your YubiKey become invalidated.<br /><br />Code:' . KeyGenius::generateRevocation($this->getValue('token'));
	}

	public function getTitle() {
		return 'Generate revocation code';
	}

	public function getDescription() {
		return 'Generate a code that you can use to delete all your stored passwords from the site. You should keep this code in a safe place to use if you were to lose your YubiKey.';
	}

	public function configure() {
		$this->setWidgets(array(
			'token'		=> new sfWidgetFormInput(),
		));

		$this->widgetSchema->setNameFormat(self::NAME.'[%s]');

		$this->setValidators(array(
			'token'		=> new sfValidatorRegex(array('pattern' => self::OTP_PATTERN)),
		));
	}
}

?>
